import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UserModule } from './service/user/user.module';
import { ConfigModule } from '@nestjs/config';
import { MysqlModule } from './db/mysql/mysql.module';
// import { RedisModule } from './db/redis/redis.module';
import { AuthModule } from './service/auth/auth.module';
// import { JwtAuthStrategy } from './common/jwt/jwt.strategy';
import { JwtAuthGuard } from './common/jwt/jwt.grad';
import { APP_GUARD } from '@nestjs/core';
import { MenuModule } from './service/menu/menu.module';
import { SystemModule } from './service/system/system.module';
import { ToolsModule } from './service/tools/tools.module';
import { ReaderModule } from './service/reader/reader.module';
@Module({
  imports: [
    // forRoot() 方法就是读取根目录下的 .env 文件
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: [
        `.env${process.env.RUNNING_ENV && '.' + process.env.RUNNING_ENV}`,
        '.env',
      ],
      expandVariables: true,
    }),
    // RedisModule,
    ToolsModule,
    MysqlModule,
    UserModule,
    AuthModule,
    MenuModule,
    SystemModule,
    ReaderModule,
  ],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: APP_GUARD,
      useClass: JwtAuthGuard,
    },
  ],
})
export class AppModule {}
